<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../引入vue2.js"></script>
</head>

<body>
    <div id="app">
        <input type="text" @input="handleInput" v-model="myText">
        <ul>
            <li v-for="item in list" :key="item">
                {{item}}
            </li>
        </ul>
    </div>
</body>
<script>
    let vm = new Vue({
        el: '#app',
        data: {
            myText: '',
            list: ["aaa", "add", "bbb", "bbc", "ccc", "ddd", "eee", "ade"],
            backup: ["aaa", "add", "bbb", "bbc", "ccc", "ddd", "eee", "ade"],
        },
        methods: {
            handleInput() {
                console.log('input', this.myText);
                // 重新赋值
                this.list = this.backup.filter(item =>
                    item.includes(this.myText)
                )
            }
        },
    })


    // filter 回顾
    let arr = [1, 2, 3, 4, 5];
    let arr2 = arr.filter(item => {
        if (item > 3) {
            return true;
        }
    });
    console.log(arr, arr2);
</script>

</html>